home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -seriously_amiga- / programming / other / cyberxxxsrc / decoder / txt / decodetwos.c < prev    next >
C/C++ Source or Header  |  1999-02-08  |  2KB  |  95 lines

  1. /*
  2. sc:c/sc opt txt/DecodeTWOS.c
  3. */
  4.  
  5. #include "Decode.h"
  6.  
  7. struct TWOSData {
  8.   ulong dummy;
  9. };
  10.  
  11. /* /// "DecodeTWOS8Mono()" */
  12. __asm ulong DecodeTWOS8Mono(REG(a0) uchar *from,
  13.                             REG(a1) uchar *toL,
  14.                             REG(a2) uchar *toR,
  15.                             REG(d0) ulong size,
  16.                             REG(a3) struct TWOSData *spec)
  17. {
  18.   ulong s, sr, d;
  19.  
  20.   s=sr=size;
  21.   while(s--) {
  22.     d=*from++;
  23.     if (d & 0x80) d-=0x100;
  24.     *toL++=d;
  25.   }
  26.   return sr;
  27. }
  28. /* \\\ */
  29.  
  30. /* /// "DecodeTWOS8Stereo()" */
  31. __asm ulong DecodeTWOS8Stereo(REG(a0) uchar *from,
  32.                               REG(a1) uchar *toL,
  33.                               REG(a2) uchar *toR,
  34.                               REG(d0) ulong size,
  35.                               REG(a3) struct TWOSData *spec)
  36. {
  37.   ulong s, sr, d;
  38.  
  39.   s=sr=size/2;
  40.   while(s--) {
  41.     d=from[0];
  42.     if (d & 0x80) d-=0x100;
  43.     *toL++=d;
  44.     d=from[1];
  45.     if (d & 0x80) d-=0x100;
  46.     *toR++=d;
  47.     from+=2;
  48.   }
  49.   return sr;
  50. }
  51. /* \\\ */
  52.  
  53. /* /// "DecodeTWOS16Mono()" */
  54. __asm ulong DecodeTWOS16Mono(REG(a0) ushort *from,
  55.                              REG(a1) short *toL,
  56.                              REG(a2) short *toR,
  57.                              REG(d0) ulong size,
  58.                              REG(a3) struct TWOSData *spec)
  59. {
  60.   ulong s, sr, d;
  61.  
  62.   s=sr=size/2;
  63.   while(s--) {
  64.     d=*from++;
  65.     if (d & 0x8000) d-=0x10000;
  66.     *toL++=d;
  67.   }
  68.   return sr;
  69. }
  70. /* \\\ */
  71.  
  72. /* /// "DecodeTWOS16Stereo()" */
  73. __asm ulong DecodeTWOS16Stereo(REG(a0) ushort *from,
  74.                                REG(a1) short *toL,
  75.                                REG(a2) short *toR,
  76.                                REG(d0) ulong size,
  77.                                REG(a3) struct TWOSData *spec)
  78. {
  79.   ulong s, sr, d;
  80.  
  81.   s=sr=size/4;
  82.   while(s--) {
  83.     d=from[0];
  84.     if (d & 0x8000) d-=0x10000;
  85.     *toL++=d;
  86.     d=from[1];
  87.     if (d & 0x8000) d-=0x10000;
  88.     *toR++=d;
  89.     from+=2;
  90.   }
  91.   return sr;
  92. }
  93. /* \\\ */
  94.  
  95.